package com.txby.dplus.identify.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.txby.dplus.common.controller.CommonController;
import com.txby.dplus.common.utils.R;
import com.txby.dplus.core.entity.DataSourceCnf;

import lombok.extern.slf4j.Slf4j;


/**
 * API登录授权
 */

@Slf4j
@RestController
@RequestMapping("/api")
public class ApiController extends CommonController{

    /**
     * 登录
     */
    @GetMapping("login")
    public R login(String mobile, String password){
     /*   Assert.isBlank(mobile, "手机号不能为空");
        Assert.isBlank(password, "密码不能为空");*/
      /*  long expires=springEhcacheUtil.getCacheManager().getCache("apiTokenCache").getCacheConfiguration().getTimeToIdleSeconds();*/
//        System.out.println(expires);
        log.info("ffffffffffffffffffffffffffffffffffffff");
        //生成token
        Map<String, Object> map =new HashMap();
        map.put("mobile", mobile);
        map.put("password", password);
        List l=mBaseDao.findAll(DataSourceCnf.class);
        System.out.println(JSON.toJSON(l));


      /*  springEhcacheUtil.put(apiTokenCachName, "user1", "test");
        springEhcacheUtil.put(apiTokenCachName, "user2", "test2");
        springEhcacheUtil.getListByLike(apiTokenCachName, "user", true);*/

        return R.ok(map);
    }
    @GetMapping("test")
    public Map test(){
    	
    	log.info("ffffffffffffffffffffffffffffffffffffff");
    	 String sql=" select * from  cm" ;
    	  List  l=this.mBaseDao.findBySql(sql, null, null);
    	 	System.out.println("==="+JSON.toJSON(l));
           Map m=new HashMap();
    	m.put("data", l);
    	return R.ok(m);
    }
    
}
